import {Dialog} from "cube-ui";
let dialog
export function showAlert(title,icon,content) {
    return new Promise(resolve => {
        dialog =   Dialog.$create({
            type: 'alert',
            title: title,
            content: content,
            icon: icon?icon:'cubeic-alert',
            onConfirm:()=>{
                resolve();
            }
        }).show()
    })
}

export function showConfirm(title,content) {
    return new Promise(resolve => {
        dialog =   Dialog.$create({
            type: 'confirm',
            icon: 'cubeic-alert',
            title: title,
            content: content,
            confirmBtn: {
                text: '确定',
                active: true,
                disabled: false,
                href: 'javascript:;'
            },
            cancelBtn: {
                text: '取消',
                active: false,
                disabled: false,
                href: 'javascript:;'
            },
            onConfirm: () => {
                resolve(true)
            },
            onCancel: () => {
                resolve(false)
            }
        }).show()
    })

}

export function showCorrect(content) {
   return  showAlert(content,'cubeic-ok')
}

export function hide() {
    dialog.hide()
}